package com.example.fmgidsprototype.data;

import android.database.sqlite.SQLiteDatabase;
import android.provider.BaseColumns;

public class VenueTable {
	
	public static final String TABLE_NAME = "Venue";
	
	public static class VenueColumns implements BaseColumns{
		public static final String JSON_ID = "json_id";
		public static final String NAME = "name";
		public static final String DESCRIPTION = "description";
		public static final String ADDRESS = "address";
		public static final String THUMB_NAME = "thumb_name";
		public static final String IMAGE_URL = "image_url";		
		public static final String URL = "url";
		public static final String EMAIL = "email";
		public static final String PHONE = "phone";
		public static final String AUDIO_PATH = "audio_path";
		public static final String RATING = "rating";
	}
	
	public static void onCreate(SQLiteDatabase db){
		StringBuilder sb = new StringBuilder();
		sb.append("create table if not exists " + VenueTable.TABLE_NAME + " (");
		sb.append(BaseColumns._ID + " integer primary key, ");
		sb.append(VenueColumns.JSON_ID + " integer unique, ");
		sb.append(VenueColumns.NAME + " text not null, ");
		sb.append(VenueColumns.DESCRIPTION + " text, ");
		sb.append(VenueColumns.ADDRESS + " text, ");
		sb.append(VenueColumns.THUMB_NAME + " text, ");
		sb.append(VenueColumns.IMAGE_URL + " text, ");	
		sb.append(VenueColumns.URL + " text, ");
		sb.append(VenueColumns.EMAIL + " text, ");
		sb.append(VenueColumns.PHONE + " text, ");
		sb.append(VenueColumns.AUDIO_PATH + " text, ");
		sb.append(VenueColumns.RATING + " numeric");
		sb.append(")");
		db.execSQL(sb.toString());
	}
	
	public static void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
		db.execSQL("drop table if exists " + VenueTable.TABLE_NAME);
		onCreate(db);
	}

}
